<template>
  <div class="inputBottom" :style="{ left, top, right, bottom }">
    <el-popover placement="right" v-model="visible">
      <div class="input">
        <el-input
          type="textarea"
          :rows="2"
          placeholder="请输入玻璃数"
          v-model="textarea"
        >
        </el-input>
        <div
          class="footer"
          :style="{
            display: 'flex',
            flexDirection: 'row-reverse',
            marginTop: '10px',
          }"
        >
          <el-button
            type="primary"
            style="marginleft: 5px"
            size="mini"
            @click="handlerConfirm"
            >确定</el-button
          >
          <el-button @click="deleteValue" style="marginleft: 5px" size="mini"
            >清空</el-button
          >
        </div>
      </div>
      <el-button type="primary" slot="reference" :icon="icon" size="mini">
        <slot></slot>
      </el-button>
    </el-popover>
  </div>
</template>

<script>
import { setSignal } from "@/api/assembly/cage";
export default {
  props: {
    left: {
      type: String,
      default: "0%",
    },
    top: {
      type: String,
      default: "0%",
    },
    bottom: {
      type: String,
      default: "0%",
    },
    right: {
      type: String,
      default: "0%",
    },
    icon: {
      type: String,
      default: "el-icon-back",
    },
    signalNumber: {
      type: Number,
    },
  },
  data() {
    return {
      textarea: "",
      visible: false,
    };
  },
  methods: {
    handlerConfirm() {
      let params = {
        plcId: "101",
        db: "63",
        value: this.signalNumber + "," + "1," + this.textarea,
      };
      let that = this
      this.$modal
        .confirm("请确认是否强制发送信号")
        .then(function () {
          setSignal(params).then((res) => {
            that.$message({
              type: "success",
              message: res.msg,
            });
          });
        })
        .catch(() => {});
    },
    deleteValue() {},
  },
};
</script>

<style lang="less" scoped>
.inputBottom {
  position: absolute;
  width: 100px;
  height: 100px;
}
.el-icon-camera-solid {
  font-size: 20px;
}
::v--deep .footer {
  width: 100%;
  display: flex;
  flex-wrap: wrap-reverse;
}
img {
  width: 25px;
  height: 25px;
}
</style>